package com.zenchn.dynamic;

import static com.zenchn.dynamic.TSysScheduleTaskDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.zenchn.model.TSysScheduleTask;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TSysScheduleTaskDynamicMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    BasicColumn[] selectList = BasicColumn.columnList(scheduleId, createTime, scheduleName, scheduleTypeId, schedulerClass, isEnable, cron, fixedDelay, memo);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<TSysScheduleTask> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<TSysScheduleTask> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TSysScheduleTaskResult")
    Optional<TSysScheduleTask> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TSysScheduleTaskResult", value = {
        @Result(column="schedule_id", property="scheduleId", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="schedule_name", property="scheduleName", jdbcType=JdbcType.VARCHAR),
        @Result(column="schedule_type_id", property="scheduleTypeId", jdbcType=JdbcType.CHAR),
        @Result(column="scheduler_class", property="schedulerClass", jdbcType=JdbcType.VARCHAR),
        @Result(column="is_enable", property="isEnable", jdbcType=JdbcType.BIT),
        @Result(column="cron", property="cron", jdbcType=JdbcType.VARCHAR),
        @Result(column="fixed_delay", property="fixedDelay", jdbcType=JdbcType.BIGINT),
        @Result(column="memo", property="memo", jdbcType=JdbcType.VARCHAR)
    })
    List<TSysScheduleTask> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, TSysScheduleTask, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, TSysScheduleTask, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    default int deleteByPrimaryKey(String scheduleId_) {
        return delete(c -> 
            c.where(scheduleId, isEqualTo(scheduleId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    default int insert(TSysScheduleTask record) {
        return MyBatis3Utils.insert(this::insert, record, TSysScheduleTask, c ->
            c.map(scheduleId).toProperty("scheduleId")
            .map(createTime).toProperty("createTime")
            .map(scheduleName).toProperty("scheduleName")
            .map(scheduleTypeId).toProperty("scheduleTypeId")
            .map(schedulerClass).toProperty("schedulerClass")
            .map(isEnable).toProperty("isEnable")
            .map(cron).toProperty("cron")
            .map(fixedDelay).toProperty("fixedDelay")
            .map(memo).toProperty("memo")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    default int insertMultiple(Collection<TSysScheduleTask> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, TSysScheduleTask, c ->
            c.map(scheduleId).toProperty("scheduleId")
            .map(createTime).toProperty("createTime")
            .map(scheduleName).toProperty("scheduleName")
            .map(scheduleTypeId).toProperty("scheduleTypeId")
            .map(schedulerClass).toProperty("schedulerClass")
            .map(isEnable).toProperty("isEnable")
            .map(cron).toProperty("cron")
            .map(fixedDelay).toProperty("fixedDelay")
            .map(memo).toProperty("memo")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    default int insertSelective(TSysScheduleTask record) {
        return MyBatis3Utils.insert(this::insert, record, TSysScheduleTask, c ->
            c.map(scheduleId).toPropertyWhenPresent("scheduleId", record::getScheduleId)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(scheduleName).toPropertyWhenPresent("scheduleName", record::getScheduleName)
            .map(scheduleTypeId).toPropertyWhenPresent("scheduleTypeId", record::getScheduleTypeId)
            .map(schedulerClass).toPropertyWhenPresent("schedulerClass", record::getSchedulerClass)
            .map(isEnable).toPropertyWhenPresent("isEnable", record::getIsEnable)
            .map(cron).toPropertyWhenPresent("cron", record::getCron)
            .map(fixedDelay).toPropertyWhenPresent("fixedDelay", record::getFixedDelay)
            .map(memo).toPropertyWhenPresent("memo", record::getMemo)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    default Optional<TSysScheduleTask> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, TSysScheduleTask, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    default List<TSysScheduleTask> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, TSysScheduleTask, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    default List<TSysScheduleTask> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, TSysScheduleTask, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    default Optional<TSysScheduleTask> selectByPrimaryKey(String scheduleId_) {
        return selectOne(c ->
            c.where(scheduleId, isEqualTo(scheduleId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, TSysScheduleTask, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    static UpdateDSL<UpdateModel> updateAllColumns(TSysScheduleTask record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(scheduleId).equalTo(record::getScheduleId)
                .set(createTime).equalTo(record::getCreateTime)
                .set(scheduleName).equalTo(record::getScheduleName)
                .set(scheduleTypeId).equalTo(record::getScheduleTypeId)
                .set(schedulerClass).equalTo(record::getSchedulerClass)
                .set(isEnable).equalTo(record::getIsEnable)
                .set(cron).equalTo(record::getCron)
                .set(fixedDelay).equalTo(record::getFixedDelay)
                .set(memo).equalTo(record::getMemo);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TSysScheduleTask record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(scheduleId).equalToWhenPresent(record::getScheduleId)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(scheduleName).equalToWhenPresent(record::getScheduleName)
                .set(scheduleTypeId).equalToWhenPresent(record::getScheduleTypeId)
                .set(schedulerClass).equalToWhenPresent(record::getSchedulerClass)
                .set(isEnable).equalToWhenPresent(record::getIsEnable)
                .set(cron).equalToWhenPresent(record::getCron)
                .set(fixedDelay).equalToWhenPresent(record::getFixedDelay)
                .set(memo).equalToWhenPresent(record::getMemo);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    default int updateByPrimaryKey(TSysScheduleTask record) {
        return update(c ->
            c.set(createTime).equalTo(record::getCreateTime)
            .set(scheduleName).equalTo(record::getScheduleName)
            .set(scheduleTypeId).equalTo(record::getScheduleTypeId)
            .set(schedulerClass).equalTo(record::getSchedulerClass)
            .set(isEnable).equalTo(record::getIsEnable)
            .set(cron).equalTo(record::getCron)
            .set(fixedDelay).equalTo(record::getFixedDelay)
            .set(memo).equalTo(record::getMemo)
            .where(scheduleId, isEqualTo(record::getScheduleId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_schedule_task")
    default int updateByPrimaryKeySelective(TSysScheduleTask record) {
        return update(c ->
            c.set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(scheduleName).equalToWhenPresent(record::getScheduleName)
            .set(scheduleTypeId).equalToWhenPresent(record::getScheduleTypeId)
            .set(schedulerClass).equalToWhenPresent(record::getSchedulerClass)
            .set(isEnable).equalToWhenPresent(record::getIsEnable)
            .set(cron).equalToWhenPresent(record::getCron)
            .set(fixedDelay).equalToWhenPresent(record::getFixedDelay)
            .set(memo).equalToWhenPresent(record::getMemo)
            .where(scheduleId, isEqualTo(record::getScheduleId))
        );
    }
}